<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/26
  Time: 13:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>requestAttribute</title>
</head>
<body>
<%
//    设置字符编码，解决中文乱码问题
    request.setCharacterEncoding("utf-8");

//    设置属性
    request.setAttribute("userName","张三2");
    request.setAttribute("pwd","zhangsan123456");

//    删除属性
    request.removeAttribute("userName");
//    获取
    String name=(String)request.getAttribute("userName");
    System.out.println("打印输出"+name);
    if(name==null || name==""){
        System.out.println("name为空");
    }else{
        System.out.println("name不为空");
    }
%>
<p>用户名：<%=request.getAttribute("userName") %></p>
<p>密码：<%=request.getAttribute("pwd")%></p>

</body>
</html>
